<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>系统配置编辑</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/frame/font.css">
		<link rel="stylesheet" href="./css/frame/xadmin.css">
		<script type="text/javascript" src="./lib/jquery/jquery-3.3.1.min.js"></script>
		<script type="text/javascript" src="./lib/layui/layui.js"></script>
		<script type="text/javascript" src="./js/frame/xadmin.js"></script>
		<script type="text/javascript" src="./js/constant/urls.js"></script>
		<script type="text/javascript" src="./js/utils/TimeUtils.js"></script>
	</head>

	<body>
		<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			<legend>编辑系统配置信息</legend>
		</fieldset>

		<form class="layui-form" action="">
			<div class="layui-form-item">
				<label class="layui-form-label">服务器型号</label>
				<div class="layui-input-block">
					<input type="text" name="nodeModel" id="nodeModel" autocomplete="off" placeholder="请输入服务器型号" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">JAVA环境</label>
				<div class="layui-input-block">
					<input type="text" name="java" id="java" autocomplete="off" placeholder="请输入JAVA环境" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">运行环境</label>
				<div class="layui-input-block">
					<input type="text" name="running" id="running" autocomplete="off" placeholder="请输入运行环境" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">服务器IP地址</label>
				<div class="layui-input-block">
					<input type="text" name="ipAddr" id="ipAddr" autocomplete="off" placeholder="请输入服务器IP地址" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">服务器域名</label>
				<div class="layui-input-block">
					<input type="text" name="domain" id="domain" autocomplete="off" placeholder="请输入服务器域名" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">服务版本号</label>
				<div class="layui-input-block">
					<input type="text" name="serverModel" id="serverModel" autocomplete="off" placeholder="请输入服务版本号" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">数据库版本</label>
				<div class="layui-input-block">
					<input type="text" name="dbModel" id="dbModel" autocomplete="off" placeholder="请输入数据库版本" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开发者</label>
				<div class="layui-input-block">
					<input type="text" name="developer" id="developer" autocomplete="off" placeholder="请输入开发者" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">联系方式</label>
				<div class="layui-input-block">
					<input type="text" name="contactWay" id="contactWay" autocomplete="off" placeholder="请输入联系方式" class="layui-input"
					 style="width: 18.75rem;">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
		<script>
			$(function() {
				layui.use(['form', 'laydate'], function() {
					var form = layui.form,
						layer = layui.layer;
					$.ajax({
						type: "get",
						url: urls.sysUrl + 'config/last',
						async: true,
						xhrFields: {
							withCredentials: true
						},
						success: function(res) {
							if (res.errorCode === 0) {
								data = res.data;
								$('#nodeModel').val(data.nodeModel);
								$('#java').val(data.java);
								$('#running').val(data.running);
								$('#ipAddr').val(data.ipAddr);
								$('#domain').val(data.domain);
								$('#serverModel').val(data.serverModel);
								$('#dbModel').val(data.dbModel);
								$('#developer').val(data.developer);
								$('#contactWay').val(data.contactWay);
							}
						}
					});
					//监听提交
					form.on('submit(demo1)', function(data) {
						$.ajax({
							type: "post",
							url: urls.sysUrl + 'config',
							async: true,
							data: JSON.stringify(data.field),
							contentType: "application/json; charset=utf-8",
							xhrFields: {
								withCredentials: true
							},
							success: function(res) {
								if (res.errorCode === 0) {
									layer.msg(res.description, {
										icon: 6
									}, function() {
										// 获得frame索引
										var index = parent.layer.getFrameIndex(window.name);
										//关闭当前frame
										parent.layer.close(index);
									});
								} else {
									layer.msg(res.description);
								}
							}
						});
						return false;
					});
				});
			});
		</script>
	</body>

</html>
